package Day2025_04_10;

public class Demo01 {
    public String formatString (String str, char[] arg) {
        StringBuffer ret = new StringBuffer();
        int j = 0;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == '%') {
                ret.append(arg[j++]);
                i++;
            } else {
                ret.append(str.charAt(i));
            }
        }
        while (j < arg.length) {
            ret.append(arg[j++]);
        }
        return ret.toString();
    }
}
